﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true"
    CodeBehind="Edit.aspx.cs" Inherits="MVCClubSite.Web.Views.Albums.Edit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div class="contentblock">
        <table>
            <tr>
                <td>
                    <h2>
                        Album Details</h2>
                    <% using (Html.BeginForm("Update", "Albums", new { @id = ViewData.Model.Album.ID }, FormMethod.Post))
                       { %>
                    <table>
                        <tr>
                            <td colspan='2'>
                                <%=Html.Label("title", "Album Name:")%>
                            </td>
                        </tr>
                        <tr>
                            <td colspan='2'>
                                <%=Html.TextBox("title", ViewData.Model.Album.Title)%>
                            </td>
                        </tr>
                        <tr>
                            <td colspan='2'>
                                <%= Html.CheckBox("isPrivate", ViewData.Model.Album.IsPrivate)%><%= Html.Label("isPrivate", "Private")%>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="submit" value="Save" id="saveButton" />
                                <%} %>
                            </td>
                            <td>
                                <% using (Html.BeginForm("Delete", "Albums", new { @id = ViewData.Model.Album.ID }, FormMethod.Post, new { onsubmit = "return confirmDelete()" }))
                                   { %>
                                <input type="submit" value="Delete" id="deleteButton" />
                                <%} %>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <h2>
                        Upload Photo</h2>
                    <% using (Html.BeginForm("UploadImage", "Albums", new { @id = ViewData.Model.Album.ID }, FormMethod.Post, new { @enctype = "multipart/form-data" }))
                       { %>
                    <table>
                        <tr>
                            <td>
                                <label for="file">
                                    Filename:</label>
                            </td>
                            <td>
                                <input type="file" name="file" id="file" size="40" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <%=Html.Label("imageTitle", "Notes:")%>
                            </td>
                            <td>
                                <%=Html.TextBox("imageTitle")%>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td style="text-align: left;">
                                <input type="submit" name="submit" value="Save" />
                            </td>
                        </tr>
                    </table>
                    <%} %>
                </td>
            </tr>
        </table>
    </div>
    <div id="leftcolumn">
        <div class="contentblock">
            <h2>
                Album Photos</h2>
            <% using (Html.BeginForm("ImageSelected", "Albums", new { @id = ViewData.Model.Album.ID }, FormMethod.Post))
               { %>
            <div id="photos">
                <%foreach (MVCClubSite.Model.Image i in ViewData.Model.Images)
                  { %>
                <% if (i.ID == ViewData.Model.SelectedImage)
                       Response.Write("<div class='selectedalbumphoto'>");
                   else
                       Response.Write("<div class='albumphoto'>");
                %>
                <%= "<a href='/Albums/Edit/" + ViewData.Model.Album.ID + "/" + i.ID +"'>"+Html.Image("~/Images/ThumbnailImage/" + i.ID) + "</a>" %>
            </div>
            <% } %>
            <div class="clear">
            </div>
            <% } %>
        </div>
    </div>
    </div>
    <div id="rightcolumn">
        <div class="contentblock">
            <h2>
                Selected Photo</h2>
            <% if (ViewData.Model.SelectedImage != 0)
                   Response.Write(Html.Image("~/Images/LargeImage/" + ViewData.Model.SelectedImage)); %>
        </div>
    </div>

    <script type="text/javascript">
        function confirmDelete() {
            return confirm("You are about delete this album and all of its photos.  Are you sure?");
        }
    </script>

</asp:Content>
